﻿<%@ WebHandler Language="C#" Class="SaveColumnForm" %>

using System;
using System.Web;

public class SaveColumnForm : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        try
        {
            string colunmID = context.Request.QueryString["ID"];    //需要改变的栏目编号
            string formID = context.Request.QueryString["modelFormID"];  //要保存的表单编号

            Whir.Model.Whir_Column column = new Whir.BLL.Whir_Column().GetModel(int.Parse(colunmID));

            if (column != null)
            {
                if (formID != "-1")
                {
                    string strSQL =
                        String.Format("SELECT modelID, moduleMark FROM Whir_Model WHERE modelID = (SELECT Whir_ModelForm.modelID FROM Whir_ModelForm WHERE Whir_ModelForm.modelFormID = {0})", formID);
                    System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(strSQL).Tables[0];

                    if (dt.Rows.Count > 0)
                    {
                        column.moduleMark = dt.Rows[0]["moduleMark"].ToString();
                        column.modelID = int.Parse(dt.Rows[0]["modelID"].ToString());
                        column.formID = formID;

                        if (column.moduleMark == "SinglePage_v0.0.01")
                            column.IsSinglePage = true;
                        else
                            column.IsSinglePage = false;

                        new Whir.BLL.Whir_Column().Update(column);

                        context.Response.Write("var data = true;");
                    }
                    else
                        context.Response.Write("var data = false;");
                }
                else
                {
                    column.moduleMark = "";
                    column.modelID = 0;
                    column.formID = "-1";

                    new Whir.BLL.Whir_Column().Update(column);
                    context.Response.Write("var data = true;");
                }
            }
            else
                context.Response.Write("var data = false;");
        }
        catch
        {
            context.Response.Write("var data = false;");
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}